<?php

$tbl1 = 'deliver_log';
$col1 = getCol($tbl1, true);

$tbl2 = 'click_log';
$col2 = getCol($tbl2, true);

$tbl3 = 'cv_log';
$col3 = getCol($tbl3, true);

echo "<table border='0'>";
	echo "<tr>";
/*		echo "<td  style='padding-left: 20'>";
			echo "<b>Keys</b><br>";
			echo getCol('click_log', true);
		echo "</td>";
*/		echo "<td  style='padding-left: 20'>";
			echo "<b>$tbl1</b><br>";
			echo $col1;
		echo "</td>";
		echo "<td style='padding-left: 20'>";
			echo "<b>$tbl2</b><br>";
			echo $col2;
		echo "</td>";

		echo "<td style='padding-left: 20'>";
			echo "<b>$tbl3</b><br>";
			echo $col3;
		echo "</td>";


	echo "</tr>";
echo "</table>";

function getCol($tb1, $getkey=false) {
 $url = "153.122.19.2";
  $user = "";
  $pass = "";

  $db = "cyber_quest_admage_sum";

  $link = mysql_connect($url,$user,$pass);

  $sdb = mysql_select_db($db,$link);

  $sql = "SELECT * FROM ". $tb1 ." order by  id desc limit 1";
  $result = mysql_query($sql, $link);

  //$rows = mysql_num_rows($result);
  while ($row = mysql_fetch_assoc($result)) {
  	$keys = array_keys($row);
 // 	var_dump($keys);
  	$c = count($keys);
  	for ($i = 0; $i < $c; $i++) {
  		 $pr = $getkey ? $keys[$i] . ':' : '';
  		 $cols .= '<br>'. $pr . '<b>'.$row[$keys[$i]]. '</b>';
  	}
  }
  mysql_free_result($result);

  mysql_close($link);

  return $cols;

}
?>
